package 力扣日常刷题.木23一月.第07天307;

/**
 * @author 帅小伙
 * @date 2022/3/7
 * @description
 */
public class Demo08二维数组查找 {

    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix == null || matrix.length == 0|| matrix[0].length == 0) return false;
        int x = matrix.length,y = matrix[0].length;
        int curX = 0,curY = y - 1;
        while(curX < x && curY >= 0) {
            if(matrix[curX][curY] == target) return true;
            else if(matrix[curX][curY] > target) curY--;
            else curX++;
        }
        return false;
    }

}
